<?php


namespace app\manage\controller;

use app\manage\model\Token;
use think\Validate;

class Store
{

    public function __construct()
    {
        $this->token=new Token();
        $this->store=new \app\manage\model\Store();
    }

    /**
     * 列表       type 1=上架  2=下架
     */
    public function storeList(){
        $param=input();
        $page=empty($param['current_page']) ? 1 : $param['current_page'];
        $page_size=empty($param['page_num']) ? 10: $param['page_num'];
        $type=empty($param['type']) ? 1: $param['type'];

        $returnData=$this->store->storeList($param,$page,$page_size,$type);

        returnJson(200,'success',$returnData);
    }

    /**
     * 详情
     */
    public function storeDetail(){
        $store_id=input('sa_id');

        $returnData=$this->store->storeDetail($store_id);

        returnJson(200,'success',$returnData);
    }

    /**
     * 下架
     */
    public function downOperate(){
        $store_id=input('sa_id');

        $this->store->dismount($store_id,1);

        returnJson(200,'操作成功');
    }

    /**
     * 批量下架
     */
    public function downOperateAll(){
        $store_ids=input('sa_ids');//数组

        $this->store->dismount($store_ids,2);

        returnJson(200,'操作成功');
    }

    /**
     * 行业分类
     */
    public function industry(){
        $returnData=$this->store->industry();

        returnJson(200,'success',$returnData);
    }

    /**
     * 所在城市列表
     */
    public function getCity(){
        $returnData=$this->store->selectStoreAddress();

        returnJson(200,'success',$returnData);
    }

}